/*
 * @Author: zuoshentao
 * @Date: 2022-08-26
 * @LastEditors: zuoshentao
 * @LastEditTime: 2022-08-26 17:43:27
 * @Description: 环境变量配置
 * @FilePath: /src/common/envConfig.js
 */

// #ifdef H5
import configH5 from '@/shared/config/h5/config'
// #endif
// #ifdef MP-WEIXIN
import configMP from '@/shared/config/mp-weixin/config'
// #endif
import Request from 'luch-request'
let envConfig = configMP

const $zz = {
  http: new Request()
}
// 运行的平台
const RUNTIME_PLATFORM = uni.getSystemInfoSync().uniPlatform
console.log(RUNTIME_PLATFORM, "RUNTIME_PLATFORM");

if (RUNTIME_PLATFORM === 'mp-weixin') {
  // #ifdef MP-WEIXIN
  envConfig = configMP
  // #endif
} else if (RUNTIME_PLATFORM === 'web') {
  // #ifdef H5
  envConfig = configH5
  // #endif
}

// 当前的环境
const PROCESS_ENV = process.env.NODE_ENV

// 运行的系统
// const OS_SYSTEM = uni.$u.os()
console.log(uni);

export default {
  install(app: {$env: object}) {
    app.$env = {
      // 公共参数
      APP_NAME: '',
      VERSION: '1.0.0',
      // RUNTIME_PLATFORM,
      // OS_SYSTEM,
      // 环境变量
      //   ...env,
      PROCESS_ENV,
      // 平台参数
      ...envConfig
    }
    // 挂载http
    uni.$zz = $zz; 
  }
}
